<?php   
class ControllerCommonHeader extends Controller {
	protected function index() {
		$this->data['title'] = $this->document->getTitle().'   '.$this->config->get('config_title');
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$this->data['base'] = $this->config->get('config_ssl');
		} else {
			$this->data['base'] = $this->config->get('config_url');
		}
		
		$this->data['description'] = $this->document->getDescription();
		$this->data['keywords'] = $this->document->getKeywords();
		$this->data['links'] = $this->document->getLinks();	 
		$this->data['styles'] = $this->document->getStyles();
		$this->data['scripts'] = $this->document->getScripts();

		$this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8');
    
        if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$server = HTTPS_IMAGE;
		} else {
			$server = HTTP_IMAGE;
		}	
				
		if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->data['icon'] = $server . $this->config->get('config_icon');
		} else {
			$this->data['icon'] = '';
		}
		
		$this->data['name'] = $this->config->get('config_name');
				
		if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
			$this->data['logo'] = $server . $this->config->get('config_logo');
		} else {
			$this->data['logo'] = '';
		}
        $this->data['home'] = 'index.php';
        
        $this->load->model('article/category');
        $this->data['categories'] = array();
        $topcatgory = $this->model_article_category->getTopCategory();
        $path = '';
        foreach($topcatgory as $top){
            $categoryinfo = $this->model_article_category->getCategory($top['category_id']);
            $path = $this->model_article_category->getPath($top['category_id']);
            $this->data['categories'][] = array(
                'name' => $categoryinfo['name'],
                'href' => $this->url->link('article/category', '&path='.$path, 'SSL')
            );
        }
        
        
        $this->data['about'] = $this->url->link('article/view', '&path=5&article_id=10', 'SSL');
        $this->data['contact'] = $this->url->link('article/view', '&path=5&article_id=10', 'SSL');
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/common/header.tpl')) {
			$this->template = $this->config->get('config_template') . '/common/header.tpl';
		} else {
			$this->template = 'common/header.tpl';
		}
		
    	$this->render();
	} 	
}
?>